package com.xin.di.uav.applet.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xin.di.uav.applet.mapper.CityAirportMapper;
import com.xin.di.uav.applet.po.CityAirport;
import com.xin.di.uav.applet.service.ICityAirportService;
import com.xin.di.uav.common.request.order.CityAirportAddRequest;
import com.xin.di.uav.common.utils.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author LTQ
 * @since 2023-05-08
 */
@Service
public class CityAirportServiceImpl extends ServiceImpl<CityAirportMapper, CityAirport> implements ICityAirportService {

    @Autowired
    private CityAirportMapper cityAirportMapper;

    @Override
    public CityAirport add(CityAirportAddRequest cityAirportAddRequest) {
        CityAirport cityAirport = BeanUtil.copyProperties(cityAirportAddRequest, CityAirport.class);
        cityAirportMapper.insert(cityAirport);
        return cityAirport;
    }

    @Override
    public CityAirport selectByConnId(String connId) {
        QueryWrapper<CityAirport> cityAirportQueryWrapper = new QueryWrapper<>();
        cityAirportQueryWrapper.eq("conn_id", connId);
        return cityAirportMapper.selectOne(cityAirportQueryWrapper);
    }

    @Override
    public List<CityAirport> selectByConnIds(List<String> connIds) {
        QueryWrapper<CityAirport> cityAirportQueryWrapper = new QueryWrapper<>();
        cityAirportQueryWrapper.in("conn_id", connIds);
        return cityAirportMapper.selectList(cityAirportQueryWrapper);
    }
}
